package com.xiaoxie.boot.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xiaoxie.boot.bean.Role;
import com.xiaoxie.boot.dao.RoleMapper;
import com.xiaoxie.boot.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

/**
 * @author xiaoxie
 * @create 2022-03-27 22:58
 */
@Service
public class RoleServiceImpl implements RoleService {
    @Autowired
    RoleMapper roleMapper;

    @Override
    public int insertSelective(Role record) {
        int i = roleMapper.insertSelective(record);
        return i;
    }

    @Override
    public int updateByPrimaryKeySelective(Role record) {
        int i = roleMapper.updateByPrimaryKeySelective(record);
        return i;
    }

    @Override
    public Role selectByPrimaryKey(Integer id) {
        Role role = roleMapper.selectByPrimaryKey(id);
        return role;
    }

    @Override
    public PageInfo<Role> selectAllRole(Role role, Integer pageNum, Integer pageSize) {
            PageHelper.startPage(pageNum,pageSize);
            List<Role> roles = roleMapper.selectAllRole(role);
            return new PageInfo<>(roles);
    }

    @Override
    public int deleteRoleByIds(List<String> ids) {
        int i = roleMapper.deleteRoleByIds(ids);
        return i;
    }

    @Override
    public Role selectRoleName(String roleName) {
        Role role = roleMapper.selectRoleName(roleName);
        return role;
    }
}
